<?php
require_once('Kbs/Controller/Action.php');

class PageController extends Kbs_Controller_Action 
{
    public function init()
    {
        $this->view->css()->append('geshiPhp.css')
                          ->append('geshiHtml.css')
                          ->append('geshiJavascript.css');
    }

    public function indexAction() 
    {
        $this->_forward('show');
    }

    public function showAction()
    {
        if ($this->getRequest()->isGet()) {
            $pageLinkUrl = $this->_getParam('pageLinkUrl');

            $businessObj = new Kbs_Model_Business_Page();
            $page = $businessObj->findByPageLinkUrl($pageLinkUrl);

            if (is_array($page)) {
                $page = $page[0];
                if ($page->getPagePublished()) {
                    $pageDetail = $page->fetchDetailByLocale();
                    $this->view->pageContent = $pageDetail->getDetailContent();
                }
            } else {
                throw new Exception('Page not exists !');
            }
        }
    }
}